package cn.adair.oxframe.drawer;

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;

import cn.adair.oxframe.R;


public class CustomDrawer extends DrawerBase {

    private static CustomDrawer mDrawer;

    //这里可以配置抽屉开向
    public CustomDrawer() {
        this.setHasTouchOutside(true);
        this.setDrawerFromIn(DrawerFromIn.LEFT);
        this.setNavibarColor(Color.parseColor("#FFFFFF"));
    }

    public static CustomDrawer instance() {
        if (null == mDrawer) {
            mDrawer = new CustomDrawer();
        }
        return mDrawer;
    }

    private OnCustomListener mListener;

    public CustomDrawer setCustomListener(OnCustomListener listener) {
        Log.e("CustomDrawer", "-----------初始化页面监听");
        this.mListener = listener;
        return this;
    }

    @Override
    public int initLayout() {
        Log.e("CustomDrawer", "-----------初始化页面布局");
        return R.layout.drawer_custom;
    }

    private TextView custom_close;

    @Override
    public void initView(View view) {
        Log.e("CustomDrawer", "-----------初始化页面视图");
        custom_close = view.findViewById(R.id.custom_close);
        custom_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mListener.dismiss();
                dismiss();
            }
        });
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        Log.e("CustomDrawer", "-----------初始化页面数据");
    }

    public void show(@NonNull FragmentManager manager) {
        Log.e("CustomDrawer", "-----------打开抽屉");
        super.show(manager, "Custom");
    }

    public interface OnCustomListener {
        void dismiss();
    }

}
